//
//  DetailUI.swift
//  fsapp
//
//  Created by zguang on 17/8/2.
//  Copyright © 2017年 huangshengjie. All rights reserved.
//

import Foundation
import UIKit

class detailUI{
    let title = UILabel()
    let backImage = UIImageView()
    let playButton = UIButton()
    let timeSpan = UILabel()
    let money = UILabel()
    let videoCount = UIButton()
    let likeCount = UIButton()
    let coommitCount = UIButton()
    let starCount = UIButton()
    var cellBackView:UIView = {
        let view = UIView(frame:CGRect(x:0,y:0,width:SCREEN_WIDTH,height:getHeight(568)))
        return view
    }()
    
    init(_ num:Int) {
        switch num {
        case 1 :
            setUI()
            submitbackView.addSubview(closeButton)
            submitbackView.addSubview(submitButton)
            submitbackView.addSubview(commentView)
            self.commentBackview.addSubview(submitbackView)
        default:
            break
        }
        

    }
    
    
    
//MARK: -   第一节
    
    lazy var commitInput:UIButton = {
        let input = UIButton();
        input.frame = CGRect(x:width(23),y:height(15),width:width(621),height:height(60))
        input.layer.borderWidth = height(1)
        input.layer.borderColor = lineColor.cgColor
        input.layer.cornerRadius = 3
        input.resignFirstResponder()
        return input
    }()
    
    lazy var commitButton:UIButton = {
        let button = UIButton()
        button.frame = CGRect(x:SCREEN_WIDTH-width(38+56),y:height(88/2-14),width:getWidth(width:66),height:height(28))
        button.titleLabel?.font = UIFont.systemFont(ofSize: height(28))
        button.setTitle("发布", for: .normal)
        button.setTitleColor(naviColor, for: .normal)
        return button
    }()
    
    
    lazy var commentView:UITextView = {
      let text = UITextView(frame:CGRect(x:0,y:height(104),width:width(600),height:height(200)))
        
      return text
    
    }()
    
    
    lazy var submitbackView:UIView = {
      let view  = UIView(frame:CGRect(x:width(76),y:height(160),width:width(600),height:height(413)))
        view.backgroundColor = UIColor.white
        view.layer.cornerRadius = 5
        
        let label = UILabel(frame:CGRect(x:width(217),y:height(40),width:0,height:0))
        label.text = "发表评论"
        label.font  = UIFont.systemFont(ofSize: height(42))
        label.sizeToFit()
        view.addSubview(label)
        
        let viewLine = UIView()
        viewLine.frame = CGRect(x:0,y:height(320),width:width(600),height:height(1))
        viewLine.backgroundColor = lineColor
        view.addSubview(viewLine)
        
        let viewLine1 = UIView()
        viewLine1.frame = CGRect(x:width(100),y:height(90),width:width(600 - 200),height:height(1))
        viewLine1.backgroundColor = lineColor
        view.addSubview(viewLine1)

        return view
    }()
    
    lazy var commentBackview:UIView = {
        let back =    UIView(frame:CGRect(x:0,y:height(0),width:SCREEN_WIDTH,height:SCREEN_HEIGHT))
        

        back.backgroundColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.5)
    return back
    }()
    
    lazy var closeButton:UIButton = {
      let close  = UIButton(frame:CGRect(x:width(515),y:height(0),width:width(80),height:height(80)))
        close.setImage(#imageLiteral(resourceName: "叉"), for: .normal)
        close.imageEdgeInsets = UIEdgeInsetsMake(getHeight(25), width(25), getHeight(25), width(25))
        return close
    }()
    
    
    
    lazy var submitButton:UIButton = {
        let button = UIButton()
        button.frame = CGRect(x:width(492),y:height(326),width:getWidth(width:80),height:height(48))
        button.titleLabel?.font = UIFont.systemFont(ofSize: height(32))
        button.setTitle("发布", for: .normal)
        button.setTitleColor(naviColor, for: .normal)
        return button
    }()
    
    func setUI(){
        
        
    
        var countSort:UIButton = {
            let button = UIButton(frame:CGRect(x:getWidth(width: 573),y:getHeight(20),width:getWidth(width: 85),height:getHeight(26)))
            button.setTitle("价格", for: .normal)
            button.setTitleColor(UIColor.gray, for: .normal)
            button.setTitleColor(UIColor.blue, for: .selected)
            return button
        }()
        
        
        title.frame = CGRect(x:getWidth(width: 19),y:getHeight(20),width:getWidth(width: 285),height:getHeight(26))
        title.textColor = UIColor.white
        
        
        backImage.frame = CGRect(x:0,y:0,width:SCREEN_WIDTH,height:getHeight(400))
        
        
        playButton.frame = CGRect(x:SCREEN_WIDTH/2 - getWidth(width: 90)/2,y:getHeight(200 - 45),width:getWidth(width: 90),height:getHeight(90))
        playButton.setImage(#imageLiteral(resourceName: "播放"), for: .normal)
        timeSpan.frame = CGRect(x:SCREEN_WIDTH - getWidth(width: 100),y:getHeight(400 - 45),width:getWidth(width: 100),height:getHeight(45))
      //  timeSpan.backgroundColor = UIColor.black
        timeSpan.textColor = UIColor.white
        
        let bottomView = UIView(frame:CGRect(x:0,y:getHeight(400),width:SCREEN_WIDTH,height:getHeight(70)))
        money.frame = CGRect(x:getWidth(width: 18),y:getHeight(20),width:getWidth(width: 76),height:getHeight(26))
        money.textColor = UIColor.red
        money.adjustsFontSizeToFitWidth = true
        
        videoCount.frame = CGRect(x:getWidth(width: 255),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
        // videoCount.titleLabel?.adjustsFontSizeToFitWidth = true
     
        videoCount.setTitleColor(UIColor.black, for: .normal)
        
        
        likeCount.frame = CGRect(x:getWidth(width: 255+38+80),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
        // likeCount.titleLabel?.adjustsFontSizeToFitWidth = true
        likeCount.setTitleColor(UIColor.black, for: .normal)
        
        
        coommitCount.frame = CGRect(x:getWidth(width: 255+(38+80)*2),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
        //coommitCount.titleLabel?.adjustsFontSizeToFitWidth = true\
        coommitCount.setTitleColor(UIColor.black, for: .normal)
        starCount.frame = CGRect(x:getWidth(width: 255 + (38+80)*3),y:getHeight(15),width:getWidth(width: 100),height:getHeight(41))
        // starCount.titleLabel?.adjustsFontSizeToFitWidth = true
        starCount.setTitleColor(UIColor.black, for: .normal)
        
        videoCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60))
        likeCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        coommitCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        starCount.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: width(60));
        videoCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-49), bottom: 0, right: 0)
        coommitCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width( -49), bottom: 0, right: 0)
        starCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-49), bottom: 0, right: 0)
        likeCount.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: width(-49), bottom: 0, right: 0)
        
        
        videoCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        starCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        coommitCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        likeCount.titleLabel?.font = UIFont.systemFont(ofSize: height(26))
        
        videoCount.titleLabel?.sizeToFit()
        starCount.titleLabel?.sizeToFit()
        likeCount.titleLabel?.sizeToFit()
        coommitCount.titleLabel?.sizeToFit()
        

        likeCount.setImage(#imageLiteral(resourceName: "点赞"), for: .normal)
        likeCount.setImage(#imageLiteral(resourceName: "点赞-红"), for: .selected)
        videoCount.setImage(#imageLiteral(resourceName: "播放量 "), for: .normal)
        coommitCount.setImage(#imageLiteral(resourceName: "评论"), for: .normal)
        starCount.setImage(#imageLiteral(resourceName: "收藏"), for: .normal)
        starCount.setImage(#imageLiteral(resourceName: "收藏-红"), for: .selected)
        
        
        let view2 = UIView(frame:CGRect(x:0,y:height(470),width:SCREEN_WIDTH,height:height(88)))
        view2.backgroundColor = UIColor.white
        view2.addSubview(commitInput)
        view2.addSubview(commitButton)
        view2.layer.borderWidth = height(1)
        view2.layer.borderColor = lineColor.cgColor
        bottomView.backgroundColor = UIColor.white
        cellBackView.backgroundColor = backColor
        bottomView.addSubview(money)
        bottomView.addSubview(videoCount)
        bottomView.addSubview(likeCount)
        bottomView.addSubview(coommitCount)
        bottomView.addSubview(starCount)
        cellBackView.addSubview(backImage)
        cellBackView.addSubview(title)
        cellBackView.addSubview(playButton)
        cellBackView.addSubview(timeSpan)
        cellBackView.addSubview(bottomView)
        cellBackView.addSubview(view2)
        //self.addSubview(cellBackView)
    }

    
    
    


    
    
    

}
